package com.baimo.support.api.mysql;

import org.apache.log4j.Logger;

/**
 * 品牌功能Controller
 * Created by wang on 2019/11/20.
 */
public class DataSourceContextHolder {
    static Logger LOG = Logger.getLogger(DataSourceContextHolder.class);
    private static final String DEFAULT_DATASOURCE = "PRIMARY_DATASOURCE";

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();

    public static void setDataSource(String dbType){
        LOG.info("切换到["+dbType+"]数据源");
        contextHolder.set(dbType);
    }

    public static String getDataSource(){
        return contextHolder.get();
    }

    public static void clearDataSource(){
        contextHolder.remove();
    }

}
